package com.blackline.parameters;

import java.io.File;
import java.util.Iterator;
import java.util.List;

import org.dom4j.Document;
import org.dom4j.DocumentException;
//import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

public class Parameters {
	private static Element root;
	private static Element sites;
	private static Element users;
//	private static Element admin;
//	private static Element preparer;
//	private static Element Approver;
//	private static Element Reviewer;

	public  String urlDev1;
	public  String urlDev2;
	public  String urlDev3;
	public  String urlDev4;
	public  String urlt2T3;
	
	public  String urlTest1;
	public  String urlTest2;
	public  String urlTest3;
	public  String urlTest4;
//	public  String AdminLoginID;
//	public  String AdminPassword;
//	public  String AdminPIN;
//	public  String PreLoginID;
//	public  String PrePassword;
//	public  String PrePIN;
//	public  String AppLoginID;
//	public  String AppPassword;
//	public  String AppPIN;
//	public  String urlT2Test1;
//	public  String urlT2Test1;
//	public  String urlT2Test1;
//	public  String urlT2Test1;
	public Parameters(String file){
		SAXReader reader=new SAXReader();
		Document doc = null;
		try {
			doc = reader.read(new File(file));
		} catch (DocumentException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		root=doc.getRootElement();
		sites=root.element("sites");
		users = root.element("users");
		
		
		urlDev1=sites.element("urlDev1").getText();
		urlDev2=sites.element("urlDev2").getText();
		urlDev3=sites.element("urlDev3").getText();
		urlDev4=sites.element("urlDev4").getText();
		urlt2T3=sites.element("urlt2T3").getText();
		
		urlTest1=sites.element("urlTest1").getText();
		urlTest2=sites.element("urlTest2").getText();
		urlTest3=sites.element("urlTest3").getText();
		urlTest4=sites.element("urlTest4").getText();
//		admin=users.element("admin");
//		AdminLoginID=admin.attributeValue("loginID");
//		AdminPassword=admin.attributeValue("password");
//		AdminPIN=admin.attributeValue("pin");
//		
//		preparer=users.element("preparer");
//		PreLoginID=preparer.attributeValue("loginID");
//		PrePassword=preparer.attributeValue("password");
//		PrePIN=preparer.attributeValue("pin");
//		
//		Approver=users.element("Approver");
//		AppLoginID=Approver.attributeValue("loginID");
//		AppPassword=Approver.attributeValue("password");
//		AppPIN=Approver.attributeValue("pin");
//		
//		Reviewer=users.element("Reviewer");
//		RevLoginID=Reviewer.attributeValue("loginID");
//		RevPassword=Reviewer.attributeValue("password");
//		RevPIN=Reviewer.attributeValue("pin");
//		
//		Approver=users.element("Approver");
//		AppLoginID=Approver.attributeValue("loginID");
//		AppPassword=Approver.attributeValue("password");
//		AppPIN=Approver.attributeValue("pin");
//		
//		Approver=users.element("Approver");
//		AppLoginID=Approver.attributeValue("loginID");
//		AppPassword=Approver.attributeValue("password");
//		AppPIN=Approver.attributeValue("pin");
//		
//		Approver=users.element("Approver");
//		AppLoginID=Approver.attributeValue("loginID");
//		AppPassword=Approver.attributeValue("password");
//		AppPIN=Approver.attributeValue("pin");
//		
//		Approver=users.element("Approver");
//		AppLoginID=Approver.attributeValue("loginID");
//		AppPassword=Approver.attributeValue("password");
//		AppPIN=Approver.attributeValue("pin");
//		
//		Approver=users.element("Approver");
//		AppLoginID=Approver.attributeValue("loginID");
//		AppPassword=Approver.attributeValue("password");
//		AppPIN=Approver.attributeValue("pin");
//		
//		Approver=users.element("Approver");
//		AppLoginID=Approver.attributeValue("loginID");
//		AppPassword=Approver.attributeValue("password");
//		AppPIN=Approver.attributeValue("pin");
	}
	public String getSite(String node){
		return sites.element(node).getText();
	}
	public String getFullName(String node){
		return users.element(node).attributeValue("fullName");
	}
	public String getLogonID(String node){
		return users.element(node).attributeValue("loginID");
	}
	public String getPassword(String node){
		return users.element(node).attributeValue("password");
	}
	public String getPIN(String node){
		return users.element(node).attributeValue("pin");
	}
	@SuppressWarnings("unused")
	private Element searchNode(String nodeName){
		Element ele = null;
		@SuppressWarnings("unchecked")
		List<Element> li=root.elements();
		Iterator<Element> i=li.iterator();
		while(i.hasNext()){
			ele=(Element)i.next();
			if(ele.getName().equals(nodeName)){
				break;
			}
		}
		return ele;
	}
}
